package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoTrainingInformationPicture;
import com.muyu.danmo.service.IDanmoTrainingInformationPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 培训班相关照片Controller
 *
 * @author yangle
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/trainingPicture")
public class DanmoTrainingInformationPictureController extends BaseController
{
    @Autowired
    private IDanmoTrainingInformationPictureService danmoTrainingInformationPictureService;

    /**
     * 查询培训班相关照片列表
     */
//    @RequiresPermissions("system:picture:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoTrainingInformationPicture>> list(DanmoTrainingInformationPicture danmoTrainingInformationPicture)
    {
        startPage();
        List<DanmoTrainingInformationPicture> list = danmoTrainingInformationPictureService.selectDanmoTrainingInformationPictureList(danmoTrainingInformationPicture);
        return getDataTable(list);
    }

    /**
     * 导出培训班相关照片列表
     */
//    @RequiresPermissions("system:picture:export")
    @Log(title = "培训班相关照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoTrainingInformationPicture danmoTrainingInformationPicture)
    {
        List<DanmoTrainingInformationPicture> list = danmoTrainingInformationPictureService.selectDanmoTrainingInformationPictureList(danmoTrainingInformationPicture);
        ExcelUtil<DanmoTrainingInformationPicture> util = new ExcelUtil<DanmoTrainingInformationPicture>(DanmoTrainingInformationPicture.class);
        util.exportExcel(response, list, "培训班相关照片数据");
    }

    /**
     * 获取培训班相关照片详细信息
     */
//    @RequiresPermissions("system:picture:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoTrainingInformationPictureService.selectDanmoTrainingInformationPictureById(id));
    }

    /**
     * 新增培训班相关照片
     */
//    @RequiresPermissions("system:picture:add")
    @Log(title = "培训班相关照片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoTrainingInformationPicture danmoTrainingInformationPicture)
    {
        return toAjax(danmoTrainingInformationPictureService.insertDanmoTrainingInformationPicture(danmoTrainingInformationPicture));
    }

    /**
     * 修改培训班相关照片
     */
//    @RequiresPermissions("system:picture:edit")
    @Log(title = "培训班相关照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoTrainingInformationPicture danmoTrainingInformationPicture)
    {
        return toAjax(danmoTrainingInformationPictureService.updateDanmoTrainingInformationPicture(danmoTrainingInformationPicture));
    }

    /**
     * 删除培训班相关照片
     */
//    @RequiresPermissions("system:picture:remove")
    @Log(title = "培训班相关照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoTrainingInformationPictureService.deleteDanmoTrainingInformationPictureByIds(ids));
    }
}
